package com.itheima.interface3;

public class ClassDataImpl1 implements ClassData{

    private Student[] students;

    public ClassDataImpl1(Student[] students) {
        this.students = students;
    }
    @Override
    public void printAllStudentInfo() {

        System.out.println("全班学生信息如下：");
        for (Student s : students) {
            System.out.println(s);
        }
        /*for (int i = 0; i < students.length; i++) {
            Student s = students[i];
            System.out.println(s);
            //System.out.println(s.getName()+"；"+s.getGender()+"；"+s.getScore());
        }*/

    }

    @Override
    public void printAverageScore() {
        double sum = 0;
        for (Student s : students) {
            sum += s.getScore();
        }
        /*for (int i = 0; i < students.length; i++) {
            Student s = students[i];
            sum += s.getScore();
        }*/
        System.out.println("全班平均成绩为：" + sum / students.length);

    }

}
